Subject: Re: Find device name and unit number
From: [email-masked] (James Cooper)
Date: 4 Feb 94 16:28:29 GMT
Newsgroups: comp.sys.amiga.programmer

In article <[email-masked]>, [email-masked] (Philip D'Ath) writes:
>I am maintaining an application, and need to be able to find out the device
>name and unit number from a reference such as "DH0".
>
>So, for example, lets say that someone has a GVP hard drive, that is
>called DH0:.  If DH0: is selected, then I want to be able to find out
>that it is using the device "gvpscsi.device", and unit x.
>
>I've had a look through a reasonable amount of documentation, but haven't
>managed to find a method to do this yet.

#include <dos/dosextens.h>
#include <dos/filehandler.h>

...
        struct DosList *dlist, *tdlist;
        struct FileSysStartupMsg *fssm;
        ULONG unit;
        char dvrname[34], *nptr;
        int i;

        dlist = LockDosList(LDF_DEVICES|LDF_READ);

        tdlist = dlist;
        tdlist = FindDosEntry(tdlist, "DH0", LDF_DEVICES);

        fssm = (struct FileSysStartupMsg *)BADDR(tdlist->dol_Startup);

        strcpy(dvrname, (char *)BADDR(fssm->fssm_Device));
        unit = fssm->fssm_Unit;

        UnLockDosList(LDF_DEVICES|LDF_READ);
...

At this point, 'unit' contains the unit number, and 'drvname' has the
device driver name... you'll need to add appropriate error checking, of
course, and this will only work under 2.0+ of the OS...

-- 
---------------
Jim Cooper
([email-masked])                             bix: jcooper

Any opinions expressed herein are mine (Mine, all mine!  Ha, ha, ha!),
and not necessarily those of my employer.

Remember, "Euphemisms are for the differently brained."